{#<link rel="stylesheet" href="/static/css/bootstrap.min.css">#}
{#<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">#}
{#<link rel="stylesheet" href="/static/css/mycss.css">#}

<div class="managediv">
    <div class="test">
        <p><span>当前位置: </span><span>首页</span> > 定时任务管理</p>
    </div>
    <div class="">
        <span>搜索</span> <input type="search">
    </div>
    <div class="hostlist">
        <table class="table table-bordered table-hover" style="margin:10px;">
            <thead>
            <tr>
                <th>选择</th>
                <th>Ip</th>
                <th>主机名</th>
                <th>更新时间</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {% for k,v in data.items %}
            <tr class="listdiv">
                <td>
                    <input type="checkbox" style="margin-right: 20px;">{{ forloop.counter }}
                </td>
                <td>
                    {{ k }}
                </td>
                <td>
                    {{ v.0 }}
                </td>
                <td>
                    {{ v.1 }}
                </td>
                <td>
                    {% if v.2 ==  0 %}
                        未激活
                    {% elif v.2 == 1 %}
                        已激活
                    {% endif %}
                </td>
                <td>
                    {% if v.2 == 0 %}
                        <a href="javascript:void(0)" class="accept-host">激活</a>
                    {% elif v.2 == 1 %}
                    <a href="javascript:void(0)" class="manage-host">管理</a>
                    {% endif %}
                </td>
            </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
</div>

<script type="text/javascript">
    $(
        function abc() {
            $(".accept-host").click(function () {
                var Ip = $(this).parents("tr").find("td").eq(1).html();
                $.ajax({
                    url: '/accept/',
                    type: 'POST',
                    data: {'IpAddress': Ip},
                    success: function (result) {
                       $(".menu li.active a").click();
                    },
                    error: function (result) {
                        alert(result);
                    }
                })
            });
            $(".manage-host").click(function () {
                var Ip = $(this).parents("tr").find("td").eq(1).html();
                $.ajax({
                    url: '/manage-host/',
                    type: 'GET',
                    data: {'IpAddress': Ip},
                    success: function (result) {
                        $(".managediv").empty();
                        $(".managediv").append(result);
                    },
                    error: function (result) {
                        alert(result);
                    }
                })

            })

        }
    )
</script>